<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('角色列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            大屏名称：<input type="text" name="visualName"/>
                        </li>
                        <li>
                            用户名称：<input type="text" name="createName"/>
                        </li>

                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]" />
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]" />
                        </li>

                        <li class="select-Num">
                            <label style="width: 100px" >包含元素数量： </label>
                            <input type="text" style="width: 80px"  placeholder="起始数量" name="params[beginNum]" />
                            <span>-</span>
                            <input type="text" style="width: 80px"  placeholder="结束数量" name="params[endNum]" />
                        </li>

                        <li th:if="${groupId}">
                            <input type="hidden" th:value="${groupId}" name="groupId"/>
                        </li>
                        <li>
                            发布状态：
                            <select id="onlineStatus" required th:with="type=${@dict.getType('online_status')}" th:name="onlineStatus">
                                <option value="">--选择发布状态查询--</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">

            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:UserVisualBase:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:UserVisualBase:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:UserVisualBase:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:UserVisualBase:remove')}]];
    var datas = [[${@dict.getType('online_status')}]];
    var prefix = ctx + "system/UserVisualBase";

    var prefix1 = ctx + "system/userModel";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            //sortName: "roleSort",
            modalName: "大屏",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'visualName',
                    title: '大屏名称'
                },
                {
                    field: 'visualCount',
                    title: '所含元素数量',
                    sortable: true
                },
                {
                    field: 'picUrl',
                    title: '封面',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        return $.table.imageView(ctx + value);
                    }
                },
                {
                    field: 'onlineStatus',
                    title: '发布状态',
                    sortable: true,
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'createName',
                    title: '创建用户',
                    sortable: true
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="showJson(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看样式JSON</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="showElements(\'' + row.id + '\','+'\''+row.visualName+'\')"><i class="fa fa-edit"></i>查看大屏元素</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function showJson(id) {

        var width = 800;
        var height = ($(window).height() - 50);

        layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: "查看样式JSON",
            content: prefix +  "/showCssJson/"  + id,
            btn: [ '关闭'],
            // 弹层外区域关闭
            shadeClose: true
        })
    }

    function showElements(baseId,visualName){
        $.modal.openTab("查看"+visualName+"大屏包含元素", prefix1+"?baseId="+baseId);
    }


</script>
</body>
</html>